<template>
  <div class="toptag">
    <el-row :gutter="5">
      <el-col :span="4">
        <div class="imgupload">
<!--          <svg-icon class-name="upload" icon-class="upload"/>-->
          <img v-if="EduxcloudCourse.largePicture" :src="EduxcloudCourse.largePicture" alt class="img" style="width:100%;">
        </div>
      </el-col>
      <el-col :span="3" :offset="2">
        <div class="subjectmsg">
          <div class="title">{{EduxcloudCourse.title}}</div>
          <div class="cost">
            <span style="color:red;">￥</span>
            <span style="color:red;">{{EduxcloudCourse.price}}</span>
          </div>
        </div>
      </el-col>
      <el-col :span="5" :offset="5">
        <div class="msgwrap">
          <span class="student">课程学员</span>
          <div style="font-size:16px;">{{EduxcloudCourse.studentNum}}</div>
        </div>
<!--        <div class="planwrap">-->
<!--          <span class="plan">课程计划</span>-->
<!--          <div style="font-size:16px;">0</div>-->
<!--        </div>-->
      </el-col>
      <el-col :span="5">
        <div class="publish">
<!--          <el-button type="info">预览课程</el-button>-->
          <el-button type="primary" @click="updateCourse">发布课程</el-button>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
  import {updateCourseStatus} from '@/api/subject/course' // 数据接口
  // import eventBus from '@/eventBus'

  export default {
    data() {
      return {
        EduxcloudCourse: {}
      }
    },
    created() {
      this.EduxcloudCourse = this.$route.params
      if (this.$route.query.title) {
        this.EduxcloudCourse.title = this.$route.query.title
      }
    },
    methods: {
      updateCourse() {
        if (this.EduxcloudCourse.id) {
          this.EduxcloudCourse.status = 'published';
          updateCourseStatus(this.EduxcloudCourse).then(response => {
            if (response.code === 200) {
              this.$notify({
                title: '成功',
                message: '发布成功',
                type: 'success',
                duration: 2000
              })
            }
          })
        } else {
          this.$message.error('请先创建课程!')
        }
      },
    }
  }
</script>

<style lang="scss" scoped>
  .toptag {
    .el-row {
      border-radius: 8px;
      padding: 2px;

      .imgupload {
        width: 300px;
        border-radius: 4px;
        cursor: pointer;
        text-align: center;
      }

      .subjectmsg {
        box-sizing: border-box;
        padding: 40px 0 20px 10px;

        .title {
          display: block;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
          word-wrap: normal;
          font-size: 20px;
          color: #5a5a5a;
        }

        .cost {
          display: block;
          margin-top: 30px;
          line-height: 1;
          font-size: 16px;
        }
      }

      .msgwrap {
        float: right;
        height: 90px;
        margin-top: 40px;
        line-height: 40px;
        width: 120px;
        text-align: center;
        border-left: 1px solid #e3e3e3;

        .student {
          display: inline-block;
          margin-top: 10px;
          color: #5a5a5a;
        }
      }

      .planwrap {
        float: right;
        height: 90px;
        margin-top: 40px;
        line-height: 40px;
        width: 120px;
        text-align: center;

        .plan {
          display: inline-block;
          margin-top: 10px;
          color: #5a5a5a;
        }
      }

      .publish {
        height: 90px;
        margin-top: 40px;
        text-align: center;
        line-height: 90px;
      }
    }

    .upload {
      width: 80px;
      height: 80px;
    }
  }
</style>
